home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 741 / rkrm_lib1 / rkrm_lib1.lha / Intuition / Images_Text / compleximage.c < prev    next >
C/C++ Source or Header  |  1992-09-03  |  6KB  |  176 lines

  1. ;/* compleximage.c - program to show the use of a complex Intuition Image.
  2. lc -b1 -cfist -v -y -j73 compleximage.c
  3. blink FROM LIB:c.o compleximage.o TO compleximage LIB LIB:lc.lib LIB:amiga.lib
  4. quit
  5. */
  6.  
  7. /*
  8. Copyright (c) 1992 Commodore-Amiga, Inc.
  9.  
  10. This example is provided in electronic form by Commodore-Amiga, Inc. for
  11. use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  12. published by Addison-Wesley (ISBN 0-201-56774-1).
  13.  
  14. The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  15. information on the correct usage of the techniques and operating system
  16. functions presented in these examples.  The source and executable code
  17. of these examples may only be distributed in free electronic form, via
  18. bulletin board or as part of a fully non-commercial and freely
  19. redistributable diskette.  Both the source and executable code (including
  20. comments) must be included, without modification, in any copy.  This
  21. example may not be published in printed form or distributed with any
  22. commercial product.  However, the programming techniques and support
  23. routines set forth in these examples may be used in the development
  24. of original executable software products for Commodore Amiga computers.
  25.  
  26. All other rights reserved.
  27.  
  28. This example is provided "as-is" and is subject to change; no
  29. warranties are made.  All use is at your own risk. No liability or
  30. responsibility is assumed.
  31. */
  32.  
  33.  
  34. #define INTUI_V36_NAMES_ONLY
  35.  
  36. #include <exec/types.h>
  37. #include <intuition/intuition.h>
  38. #include <intuition/intuitionbase.h>
  39.  
  40. #include <clib/exec_protos.h>
  41. #include <clib/dos_protos.h>
  42. #include <clib/intuition_protos.h>
  43.  
  44. #include <stdio.h>
  45.  
  46. #ifdef LATTICE
  47. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  48. int chkabort(void) { return(0); }  /* really */
  49. #endif
  50.  
  51. struct IntuitionBase *IntuitionBase = NULL;
  52.  
  53. #define MYIMAGE_LEFT    (0)
  54. #define MYIMAGE_TOP     (0)
  55. #define MYIMAGE_WIDTH   (24)
  56. #define MYIMAGE_HEIGHT  (10)
  57. #define MYIMAGE_DEPTH   (2)
  58.  
  59. /* This is the image data.  It is a two bitplane open rectangle which
  60. ** is 24 pixels wide and 10 high.  Make sure that it is in CHIP memory,
  61. ** or allocate a block of chip memory with a call like:
  62. **
  63. **     AllocMem(data_size,MEMF_CHIP)
  64. **
  65. ** and copy the data to that block.  See the Exec chapter on
  66. ** Memory Allocation for more information on AllocMem().
  67. */
  68. UWORD __chip myImageData[] =
  69.     {
  70.     /* first bitplane of data,
  71.     ** open rectangle.
  72.     */
  73.     0xFFFF, 0xFF00,
  74.     0xC000, 0x0300,
  75.     0xC000, 0x0300,
  76.     0xC000, 0x0300,
  77.     0xC000, 0x0300,
  78.     0xC000, 0x0300,
  79.     0xC000, 0x0300,
  80.     0xC000, 0x0300,
  81.     0xC000, 0x0300,
  82.     0xFFFF, 0xFF00,
  83.  
  84.     /* second bitplane of data,
  85.     ** filled rectangle to appear within open rectangle.
  86.     */
  87.     0x0000, 0x0000,
  88.     0x0000, 0x0000,
  89.     0x0000, 0x0000,
  90.     0x00FF, 0x0000,
  91.     0x00FF, 0x0000,
  92.     0x00FF, 0x0000,
  93.     0x00FF, 0x0000,
  94.     0x0000, 0x0000,
  95.     0x0000, 0x0000,
  96.     0x0000, 0x0000,
  97.     };
  98.  
  99. /* used to get the "new look" on a custom screen */
  100. UWORD pens[] = { ~0 };
  101.  
  102.  
  103. /*
  104. ** main routine. Open required library and window and draw the images.
  105. ** This routine opens a very simple window with no IDCMP.  See the
  106. ** chapters on "Windows" and "Input and Output Methods" for more info.
  107. ** Free all resources when done.
  108. */
  109. VOID main(int argc, char *argv[])
  110. {
  111. struct Screen *scr;
  112. struct Window *win;
  113. struct Image myImage;
  114.  
  115. IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37);
  116. if (IntuitionBase != NULL)
  117.     {
  118.     if (NULL != (scr = OpenScreenTags(NULL,
  119.                         SA_Depth,       4,
  120.                         SA_Pens,        &pens,
  121.                         TAG_END)))
  122.         {
  123.         if (NULL != (win = OpenWindowTags(NULL,
  124.                             WA_RMBTrap,      TRUE,
  125.                             WA_CustomScreen, scr,
  126.                             TAG_END)))
  127.             {
  128.             myImage.LeftEdge    = MYIMAGE_LEFT;
  129.             myImage.TopEdge     = MYIMAGE_TOP;
  130.             myImage.Width       = MYIMAGE_WIDTH;
  131.             myImage.Height      = MYIMAGE_HEIGHT;
  132.             myImage.Depth       = MYIMAGE_DEPTH;
  133.             myImage.ImageData   = myImageData;
  134.             myImage.PlanePick   = 0x3;              /* use first two bitplanes */
  135.             myImage.PlaneOnOff  = 0x0;              /* clear all unused planes  */
  136.             myImage.NextImage   = NULL;
  137.  
  138.             /* Draw the image into the first two bitplanes */
  139.             DrawImage(win->RPort,&myImage,10,10);
  140.  
  141.             /* Draw the same image at a new location */
  142.             DrawImage(win->RPort,&myImage,100,10);
  143.  
  144.             /* Change the image to use the second and fourth bitplanes,
  145.             ** PlanePick is 1010 binary or 0xA,
  146.             ** and draw it again at a different location
  147.             */
  148.             myImage.PlanePick = 0xA;
  149.             DrawImage(win->RPort,&myImage,10,50);
  150.  
  151.             /* Now set all the bits in the first bitplane with PlaneOnOff.
  152.             ** This will make all the bits set in the second bitplane
  153.             ** appear as color 3 (0011 binary), all the bits set in the
  154.             ** fourth bitplane appear as color 9 (1001 binary) and all
  155.             ** other pixels will be color 1 (0001 binary.  If there were
  156.             ** any points in the image where both bits were set, they
  157.             ** would appear as color 11 (1011 binary).
  158.             ** Draw the image at a different location.
  159.             */
  160.             myImage.PlaneOnOff = 0x1;
  161.             DrawImage(win->RPort,&myImage,100,50);
  162.  
  163.             /* Wait a bit, then quit.
  164.             ** In a real application, this would be an event loop, like the
  165.             ** one described in the Intuition Input and Output Methods chapter.
  166.             */
  167.             Delay(200);
  168.  
  169.             CloseWindow(win);
  170.             }
  171.         CloseScreen(scr);
  172.         }
  173.     CloseLibrary((struct Library *)IntuitionBase);
  174.     }
  175. }
  176.